﻿using UnityEngine;
using System.Collections;
using System;
using System.Collections.Generic;

public class SkillDataMgr
{

    private static SkillDataMgr _instance;

    public static SkillDataMgr instance
    {
        get
        {
            if (_instance == null)
                _instance = new SkillDataMgr();
            return _instance;
        }
    }

    public SkillDataMgr()
    {
        if (_instance != null)
        {
            throw new Exception("单例类");
        }
        SkillDataDic = new Dictionary<int, SkillEffectVo>();
    }

    private Dictionary<int,SkillEffectVo> SkillDataDic;

    public SkillEffectVo GetSkillData(int skillId)
    {
        //if (SkillDataDic.ContainsKey(skillId))
        //{
        //    return SkillDataDic[skillId];
        //}
        //else
        //{
            try
            {
                TextAsset textAsset = (TextAsset)Resources.Load("SkillData/" + skillId);
                SkillEffectVo vo =  SkillEffectVo.Create(textAsset.text);
                if(vo != null)
                {
                    SkillDataDic[skillId] = vo;
                    return vo;
                }
            }catch(Exception e)
            {
                Debug.LogError(e.ToString() + "获取技能数据失败 id=" + skillId);
                return null;
            }
            return null;
        //}

    }


}
